#include <stdio.h>

int MaxSubseqSum4(int A[], int N)
{
    int ThisSum, MaxSum;
    ThisSum = MaxSum = 0;

    for (int i = 0; i < N; i++)
    {
        ThisSum += A[i];
        if (ThisSum > MaxSum)
            MaxSum = ThisSum;
        else if (ThisSum < 0) // 如果当前子列和为负，则不可能使后面的部分和更大，抛弃之
            ThisSum = 0;
    }
    return MaxSum;
}

int main() 
{
    int List[] = {-2, 11, -4, 13, -5, -2};
    printf("%d\n", MaxSubseqSum4(List, 6));
    return 0;
} 